package com.example.shellshopping.login;

import android.content.Intent;
import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.example.shellshopping.R;
import com.example.shellshopping.utils.BaseFragment;
import com.example.shellshopping.utils.SaveUserUtils;
import com.example.shellshopping.utils.URLUtils;
import com.google.gson.Gson;

import java.util.HashMap;
import java.util.Map;


/**
 * 登录界面
 */
public class SettingGetQuestion extends BaseFragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_login, container, false);
        return view;
    }



    private UserBean.DataBean userInfo; //之前登录时保存的用户信息
    public void networkLink(){
        userInfo = SaveUserUtils.getUserInfo(getContext());

        Map<String, String> map = new HashMap<>();
        map.put("id", String.valueOf(userInfo.getId()));
        getNetwork(URLUtils.showQuestion_url, map);
    }


    @Override
    public void onSuccess(String result){
        super.onSuccess(result);
        //解析数据
        UserBean bean = new Gson().fromJson(result,UserBean.class);
        //
        int code = bean.getCode();
        switch(code){
            case 200:  //登录成功
                Toast.makeText(getContext(),"获取密保问题成功！",Toast.LENGTH_SHORT).show();
                break;
            case 201:  //账号或密码错误
                Toast.makeText(getContext(),"获取密保问题失败！",Toast.LENGTH_SHORT).show();
                break;
            default:   //其他，登录失败
                Toast.makeText(getContext(),"获取异常！",Toast.LENGTH_SHORT).show();
                break;
        }
    }


}